﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ValidateCommon;
using BusinessLogic.ClassFactory;
using BusinessLogic.BusinessRules;
using System.Text;
using Common;

namespace RichECMS.ServerPages
{
    public partial class LeftMain : Util.BasePage.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hiddenpid.Value = "0";
                InitDataBind();
                if (State.LoginUser.ManagerCompetence <= (int)Utility.ManagerCompetence.Designer)
                {
                    addnewweb.Text = "<div class='left_main menulist'><ul><li><a class='iframeright' href='SysManage/AddSebSite.aspx' title='新建网站'>新建网站</a></li></ul></div>";
                }
            }
        }

        /// <summary>
        /// 绑定
        /// </summary>
        private void InitDataBind()
        {
            try
            {
                using (UserWebRelationFactory objUserWebRelationFactory = new UserWebRelationFactory())
                {
                    UserWebRelation objUserWebRelation=objUserWebRelationFactory.CreatorBySql(" chvLoginName='"+State.LoginUser.LoginName+"'");
                    if (objUserWebRelation != null)
                    {
                        StringBuilder strWidList = new StringBuilder();
                        foreach (Model.Data.UserWebRelationData.UserWebRelationRow objRow in objUserWebRelation.Data.UserWebRelation.Rows)
                        {
                            strWidList.Append(objRow.intWSID + ",");
                        }
                        strWidList.Append("-1");
                        WebSiteFactory objWebSiteFactory = new WebSiteFactory();
                        WebSite objWebSite = objWebSiteFactory.CreatorBySql(" intWebSiteID in (" + strWidList + ")");
                        if (objWebSite != null)
                        {
                            rptList.DataSource = objWebSite.Data.WebSite.DataSet.Tables[0].DefaultView;
                            rptList.DataBind();
                        }
                        objWebSiteFactory.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                Alert(ex.ToString());
            }
        }
    }
}